<?php
/*
 * 手机客户端 获取帐户页拍品信息接口
 * 2013-11-30
 */
include "inc/public_header.php";

include "func/user.php";				//用户信息处理函数
include "func/userlastbid.php";			//最高出价信息表函数
include "func/userwon.php";				//用户支付明细函数

//图片根路径
$IMAGES_BASE_URL = "http://www.chinalaohu.com/modules/miniature.php?w=180&h=180&p=/uploads/1000*1000/"; 


//获取用户信息
$uInfoArr = user_getInfoFromUUID();
if(!$uInfoArr){
	echo json_encode(array("success"=>"0","errCode"=>"0","msg"=>"没有获取到用户信息"));
	die;
}
$uid = $uInfoArr["uid"]; //用户信息主键

$page		= $_REQUEST["page"];		//page 分页
$attention	= $_REQUEST["attention"];	//关注 1包含  0排除
$type		= $_REQUEST["type"];		//类型 0 竞拍中 1 己得标 2 未得标 3 己支付 4 未支付 5 已发货 6 未发货 7我的领先 8 我的出局

$reJson = array(); //构建返回值

$gzIds = user_gzids($uid); //获取关注展品主键（用逗号分割）

if($type=="0"){
	//竞拍中
	$userBuyerList = userlastbid_userbuyerbid($uid);
}else if($type=="1"){
	//已得标
	$userBuyerList = userlastbid_userwon($uid);
}else if($type=="2"){
	//未得标
	$userBuyerList = userlastbid_userdontwin($uid,$attention,$gzIds);
}else if($type=="3"){
	//已支付
	$userBuyerList = userwon_paidauctionlist($uid);
}else if($type=="4"){
	//未支付
	$userBuyerList = userlastbid_userwonunpay($uid);
}else if($type=="5"){
	//已发货
	$userBuyerList = userwon_shipallwonlist12($uid);
}else if($type=="6"){
	//未发货
	$userBuyerList = userwon_shipallwonlist03($uid,$attention,$gzIds);
}else if($type=="7"){
	//我的领先
	$userBuyerList = userlastbid_lingxian($uid);
}else if($type=="8"){
	//我的出局
	$userBuyerList = userlastbid_chuju($uid);
}else{
	//我关注的展品信息
	$userBuyerList = user_gzlist($gzIds);
}
$gzIds = ",".$gzIds.","; //用来判断是否存在

$count = count($userBuyerList); //记录数

$list = array(); //记录集数组
for($i=0;$i<$count;$i++){
	if(strpos($gzIds,$userBuyerList[$i]["aid"])){
		$atn = "1";
	}else{
		$atn = "0";
	}
	$list[] = array(
		 "aID"=>$userBuyerList[$i]["aid"]
		,"auctionCode"=>$userBuyerList[$i]["acode"]
		,"iconUrl"=>$IMAGES_BASE_URL.$userBuyerList[$i]["acode"]."f1.jpg"
		,"name"=>$userBuyerList[$i]["auction"]
		,"dealTime"=>$userBuyerList[$i]["endtime"]
		,"preSTime"=>$userBuyerList[$i]["prevtime"]
		,"preETime"=>$userBuyerList[$i]["starttime"]
		,"lastTime"=>$userBuyerList[$i]["endtime"]
		,"price"=>$userBuyerList[$i]["lastprice"]
		,"attention"=>$atn
		,"auctionType"=>$userBuyerList[$i]["auctiontype"]
	);
}

$reJson["success"] = "1";
$reJson["count"] = $count;
$reJson["serverTime"] = date('Y-m-d H:i:s');
$reJson["list"] = $list;

echo json_encode($reJson);
die;
?>